package com.example.sakurasay.passwordbook.data.entities

import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.ForeignKey
import androidx.room.PrimaryKey
import java.util.Date

@Entity(
    tableName = "shared_accounts",
    foreignKeys = [
        ForeignKey(
            entity = SharedPassword::class,
            parentColumns = ["id"],
            childColumns = ["password_id"],
            onDelete = ForeignKey.CASCADE
        )
    ]
)
data class SharedAccount(
    @PrimaryKey(autoGenerate = true)
    val id: Int = 0,

    @ColumnInfo(name = "password_id", index = true)
    val passwordId: Int,

    @ColumnInfo(name = "account_name")
    val accountName: String,

    @ColumnInfo(name = "username")
    val username: String,

    @ColumnInfo(name = "created_at")
    val createdAt: Date = Date(),

    @ColumnInfo(name = "updated_at")
    val updatedAt: Date = Date()
)